#pragma region License
/************************************************************************
 *                                                                      *
 * Copyright (C) 2010, 2011 Ghoul                                       *
 * All rights reserved.                                                 *
 *                                                                      *
 ************************************************************************/
#pragma endregion

#include "MSvlb.h"

BOOL bLegitBotEnabled = false;

static void EventHandler(WM_CLOSE)
    ( __in HWND hWnd );
static void EventHandler(WM_DESTROY)
    ( __in HWND hWnd );
static void EventHandler(WM_QUIT)
    ( __in HWND hWnd, __in INT iExitCode );
static void EventHandler(WM_COMMAND)
    ( __in HWND hWnd, __in INT iCtrlID, __in HWND hWndCtrl, __in DWORD dwNotify );

__inline void BotToggle ( __in HWND hWnd );

INT_PTR CALLBACK DlgProc ( __in HWND hWnd, __in UINT Msg, __in WPARAM wParam, __in LPARAM lParam )
{
    EventTable {
        MapEvent(WM_CLOSE);
        MapEvent(WM_DESTROY);
        MapEvent(WM_QUIT);
        MapEvent(WM_COMMAND);
    }
    return 0;
}

static void EventHandler(WM_CLOSE)
    ( __in HWND hWnd )
{
    DestroyWindow(hWnd);
}

static void EventHandler(WM_DESTROY)
    ( __in HWND hWnd )
{
    UNREFERENCED_PARAMETER(hWnd);
    PostQuitMessage(0);
}

static void EventHandler(WM_QUIT)
    ( __in HWND hWnd, __in INT iExitCode )
{
    UNREFERENCED_PARAMETER(hWnd);
    ExitProcess((UINT)iExitCode);
}

static void EventHandler(WM_COMMAND)
    ( __in HWND hWnd, __in INT iCtrlID, __in HWND hWndCtrl, __in DWORD dwNotify )
{
    UNREFERENCED_PARAMETER(hWndCtrl);
    UNREFERENCED_PARAMETER(dwNotify);

    switch ( iCtrlID ) {
        case IDC_CB_BOT:
            BotToggle(hWnd);
            break;
    }
}

__inline void BotToggle ( __in HWND hWnd )
{
    HRESULT hMsg = SendMessage ( GetDlgItem( hWnd, IDC_CB_BOT ), BM_GETCHECK, 0, 0);

    if (hMsg != NULL)
        bLegitBotEnabled = (BOOL)hMsg;
}